load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")

cc_library(
    name = "config",
    hdrs = ["config.h"],
    deps = ["@rules_autoconf//:config"],
    defines = select({
        "@platforms//os:windows": [
            "LIBXSLT_STATIC",
            "LIBEXSLT_STATIC",
        ],
        "//conditions:default": [],
    }),
    visibility = ["//:__subpackages__"],
)

alias(
    name = "libxslt",
    actual = "//libxslt",
)

alias(
    name = "libexslt",
    actual = "//libexslt",
)

cc_test(
    name = "libxslt_test",
    srcs = ["tests/runtest.c"],
    data = glob(["tests/**"]),
    args = ["-v"],
    env = {"TESTPLUGIN": "$(rlocationpath :tests/testplugin.c)"},
    # TODO(zbarsky): The rlocationpath hack doesn't work on Windows;
    # I don't have an easy way to debug it :(
    target_compatible_with = select({
        "@platforms//os:windows": ["@platforms//:incompatible"],
        "//conditions:default": [],
    }),
    deps = [
        "//libxslt",
        "//libexslt",
    ],
)
